package com.mundus.engine.assets;

import java.util.Calendar;
import java.util.Locale;

import org.lwjgl.Sys;

public class DateTime {
	public static long lastFrame;	
	
	private static long _lastFPS;
	private static int _fps;
	private static int _outFPS;
	
	public static int getFPS(){return _outFPS;}
	
	public static Calendar getCurrentDateTime(){
		return Calendar.getInstance(Locale.getDefault());
	}
	
	public static int getDelta(){
		long time = getTime();
		int delta = (int) (time - lastFrame);
		lastFrame = time;
		return delta;
	}

	private static long getTime() {
		return (Sys.getTime() * 1000) / Sys.getTimerResolution();
	}
	
	public static void initFPS(){
		_lastFPS = getTime();
	}
	
	public static void updateFPS(){
	    if (getTime() - _lastFPS > 1000) {
	    	_outFPS = _fps;
	        _fps = 0;
	        _lastFPS += 1000;
	    }
	    _fps++;
	}
}
